<template>
    <div>
        <h1>Login</h1>
        <input type="text" name="username" id v-model="forms.username" />
        <input type="password" name="psd" id v-model="forms.psd" />
        <div class>
        <button @click="submitForm(forms)">提交</button>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
        forms: {
            username: "",
            psd: ""
        }
        };
    },
    methods: {
        submitForm(val) {
            console.log(val);
            var {username,psd} = val;
            this.$http.post("/login",{username,psd}).then(res=>{
                if(res.data.auth){
                console.log(res)
                    this.$router.push("/home")
                }else{
                    alert(res.data.msg)
                }
            })
        }
    }
};
</script>

<style scoped>
</style>